home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / c_text.zip / P_TIME.C < prev    next >
Text File  |  1987-06-23  |  1KB  |  64 lines

  1. #include <time.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4. #include <dos.h>
  5. p_time(j_time)
  6. char *j_time;
  7. {
  8.    union REGS inreg,outreg;
  9.    static char am_pm[] = " a.m.";
  10.    char *p1,temp[20];
  11.    int rad = 10,one;
  12.  
  13.    inreg.h.ah = 44;
  14.    int86(0x21,&inreg,&outreg);
  15.    if(outreg.h.ch > 11)
  16.       {
  17.       outreg.h.ch = outreg.h.ch % 12;
  18.       if (outreg.h.ch == 0) outreg.h.ch = 12;
  19.       am_pm[1] = 'p';
  20.       }
  21.    if(outreg.h.ch < 10) one = 1; else one = 0;
  22.    p1 = itoa(outreg.h.ch,temp,rad);
  23.    if (one == 0)
  24.       {
  25.       j_time[0] = p1[0];
  26.       j_time[1] = p1[1];
  27.       }
  28.    else
  29.       {
  30.       j_time[0] = '0';
  31.       j_time[1] = p1[0];
  32.       }
  33.    j_time[2] = ':';
  34.    if(outreg.h.cl < 10) one = 1; else one = 0;
  35.    p1 = itoa(outreg.h.cl,temp,rad);
  36.    if (one == 0)
  37.       {
  38.       j_time[3] = p1[0];
  39.       j_time[4] = p1[1];
  40.       }
  41.    else
  42.       {
  43.       j_time[3] = '0';
  44.       j_time[4] = p1[0];
  45.       }
  46.    j_time[5] = ':';
  47.    if(outreg.h.dh < 10) one = 1; else one = 0;
  48.    p1 = itoa(outreg.h.dh,temp,rad);
  49.    if (one == 0)
  50.       {
  51.       j_time[6] = p1[0];
  52.       j_time[7] = p1[1];
  53.       }
  54.    else
  55.       {
  56.       j_time[6] = '0';
  57.       j_time[7] = p1[0];
  58.       }
  59.    j_time[8] = '\0';
  60.    strcat(j_time,am_pm);
  61. }
  62.  
  63.  
  64.